﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KandaAlpha.Domain.Model.Proposed.Entities
{
    public class Address : EntityBase
    {
        public Country Country { get; set; }
        
        public Region Region { get; set; }

        public City City { get; set; }

        public string SuburbName { get; set; }

        public string StreetName { get; set; }

        public string StreetNumber { get; set; }

        public string Unit { get; set; }

        public double Longitude { get; set; }

        public double Latitude { get; set; }

        public string PostCode { get; set; }

        public override string ToString()
        {
            var address = string.Empty;

            if (!string.IsNullOrEmpty(StreetNumber))
            {
                address += StreetNumber;
            }

            if (!string.IsNullOrEmpty(StreetName))
            {
                address += " " + StreetName + ", ";
            }

            if (!string.IsNullOrEmpty(SuburbName))
            {
                address += SuburbName + ", ";
            }

            if (City != null)
            {
                address += City.Name + ", ";
            }

            if (Region != null)
            {
                address += Region.Name + ", ";
            }

            if (!string.IsNullOrEmpty(PostCode))
            {
                address += PostCode;
            }
            else
            {
                address = address.Length > 0 ? address.Substring(0, address.Length - 2) : address;
            }


            return address;
        }

    }
}
